package respostas;

import comportamento.neuronio.IPerceptron;

import concreto.neuronio.PerceptronSimples;

public class AC05 {

    public static void main(String[] args) {

	double[][] padroesEntrada = {{0,0}, 
		{0,1}, 
		{1,0}, 
		{1,1}};
	
	/* Saída esperada utilizando o operador lógico AND */
	double[] saida_and = {0,0,0,1};
	
	/* Saída esperada utilizando o operador lógico OR */
	double[] saida_or = {0,1,1,1};
	
	/* Saída esperada utilizando o operador lógico NAND */
	double[] saida_nand = {1,1,1,0};
	
	/* Saída esperada utilizando o operador lógico NOR */
	double[] saida_nor = {1,0,0,0};	
	
	IPerceptron perceptron_and = new PerceptronSimples(0);
	perceptron_and.treinar(padroesEntrada, saida_and);
	
	IPerceptron perceptron_or = new PerceptronSimples(0);
	perceptron_or.treinar(padroesEntrada, saida_or);

	IPerceptron perceptron_nand = new PerceptronSimples(0);
	perceptron_nand.treinar(padroesEntrada, saida_nand);
	
	IPerceptron perceptron_nor = new PerceptronSimples(0);
	perceptron_nor.treinar(padroesEntrada, saida_nor);	
	
	System.out.println("[Porta AND]");
	System.out.println(perceptron_and);
	System.out.println("\nTeste 0,0: " +  perceptron_and.estimular(padroesEntrada[0]));
	System.out.println("Teste 0,1: " +  perceptron_and.estimular(padroesEntrada[1]));
	System.out.println("Teste 1,0: " +  perceptron_and.estimular(padroesEntrada[2]));
	System.out.println("Teste 1,1: " +  perceptron_and.estimular(padroesEntrada[3]));
	
	System.out.println("\n[Porta OR]");
	System.out.println(perceptron_or);	
	System.out.println("\nTeste 0,0: " + perceptron_or.estimular(padroesEntrada[0]));
	System.out.println("Teste 0,1: " + perceptron_or.estimular(padroesEntrada[1]));
	System.out.println("Teste 1,0: " + perceptron_or.estimular(padroesEntrada[2]));
	System.out.println("Teste 1,1: " + perceptron_or.estimular(padroesEntrada[3]));
	
	System.out.println("\n[Porta NAND]");
	System.out.println(perceptron_nand);	
	System.out.println("\nTeste 0,0: " + perceptron_nand.estimular(padroesEntrada[0]));
	System.out.println("Teste 0,1: " + perceptron_nand.estimular(padroesEntrada[1]));
	System.out.println("Teste 1,0: " + perceptron_nand.estimular(padroesEntrada[2]));
	System.out.println("Teste 1,1: " + perceptron_nand.estimular(padroesEntrada[3]));	
	
	System.out.println("\n[Porta NOR]");
	System.out.println(perceptron_nor);	
	System.out.println("\nTeste 0,0: " + perceptron_nor.estimular(padroesEntrada[0]));
	System.out.println("Teste 0,1: " + perceptron_nor.estimular(padroesEntrada[1]));
	System.out.println("Teste 1,0: " + perceptron_nor.estimular(padroesEntrada[2]));
	System.out.println("Teste 1,1: " + perceptron_nor.estimular(padroesEntrada[3]));	
    }

}
